#include <event/ssh_epoll_event.h>
#include <fort.h>
#include <ssh/client.h>
using namespace fort;

void EpollSSHEvent::wait()
{
    struct epoll_event events[10];
    while (true)
    {
        int count = epoll_wait(this->event_fd, events, 10, -1);
        for(int i = 0;i < count; i++){
            SSHFort *sdata = (SSHFort *)events[i].data.ptr;
            if( !(sdata->flag & ASSET_ERROR) && sdata->asset->channel_status() && sdata->client->channel_status()){
                int status = ssh_event_dopoll(sdata->poll_event, 2000);
                if(status < 0){
                    delete sdata;
                }
            }else{
                delete sdata;
            }
        }
    }
}
